package com.etc.team2.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.etc.team2.bean.StaToSta;
import com.etc.team2.service.StaToStaService;

public class StaToStaServlet extends HttpServlet {


	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String sname=request.getParameter("sname");
		String ename=request.getParameter("ename");
		StaToStaService stss=new StaToStaService();
		List<List> list=stss.getStaToSta(sname, ename);
		if(list.size()!=0)
		{
			request.setAttribute("stslist", list);
			int i=0;
			if(list.get(0).size()==3)
			{
				i=0;
			}
			else if(list.get(0).size()==5)
			{
				i=1;
			}
			else if(list.get(0).size()==7)
			{
				i=2;
			}
			request.setAttribute("num", i);
			request.getRequestDispatcher("stosresult.jsp").forward(request, response);
		}
		else
		{
			System.out.println("失败");
			request.getRequestDispatcher("error.jsp").forward(request, response);
		}

	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

}
